def solution(binary1, binary2):
    # 初始化结果和进位
    result = []
    carry = 0

    # 反转字符串，方便从最低位开始加
    binary1 = binary1[::-1]
    binary2 = binary2[::-1]

    # 取较长的长度
    max_length = max(len(binary1), len(binary2))

    for i in range(max_length):
        # 获取当前位的值，若超出长度则默认为 0
        bit1 = int(binary1[i]) if i < len(binary1) else 0
        bit2 = int(binary2[i]) if i < len(binary2) else 0

        # 计算当前位的和加上进位
        total = bit1 + bit2 + carry

        # 当前位的结果是 total % 2
        result.append(str(total % 2))
        # 更新进位
        carry = total // 2

    # 如果还有进位，则添加到结果中
    if carry:
        result.append(str(carry))

    # 反转结果并转换为十进制
    decimal_result = str(int(''.join(result[::-1]), 2))
    return decimal_result


if __name__ == "__main__":
    # 测试用例
    print(solution("101", "110") == "11")
    print(solution("111111", "10100") == "83")
    print(solution("111010101001001011", "100010101001") == "242420")
    print(solution("111010101001011", "10010101001") == "31220")
